package Reflect;

import Reflect.annotations.AutoRunClass;

import java.io.File;

public class Test3 {
    public static void main(String[] args) throws Exception {

        File dir = new File(Test3.class.getResource(".").toURI());
        File[] files = dir.listFiles(f -> f.getName().endsWith(".class"));

        for (File file : files){
            String name = file.getName();
            String[] data = name.split("\\.");
            String path = Test3.class.getPackage().getName() +"."+ data[0];
//            System.out.println(path);
            Class cls = Class.forName(path);
            if (cls.isAnnotationPresent(AutoRunClass.class)){
                Object obj = cls.newInstance();
                System.out.println(obj);
            }
        }
    }
}
